home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
t_os
/
gravity
/
gravity.bas
next >
Wrap
BASIC Source File
|
1993-11-30
|
952b
|
19 lines
10 RANDOMIZE TIME : SCREEN@ 0 : COLOR 7,0,,4 : CLS
11 WINDOW(0,0)-(639,479) : VIEW(0,0)-(639,479)
20 CLS:X1=RND*630+5:Y1=RND*470+5:X2=RND*630+5:Y2=RND*470+5
30 M1=RND*250+10:M2=RND*250+10:VX1=RND*3-1:VY1=RND*3-1:VX2=RND*3-1:VY2=RND*3-1
35 LOCATE 0,0:COLOR 5:PRINT "M1 -";M1,,:COLOR 6:PRINT "M2 -";M2:COLOR 7
36 LOCATE 0,23:PRINT "何かキーを押すと質量や初速が変化します。"
37 WHILE INKEY$=""
40 R=(X2-X1)*(X2-X1)+(Y2-Y1)*(Y2-Y1)
50 VX1=VX1+M2*SGN(X2-X1)/R:X1=X1+VX1:IF X1>635 OR X1<5 THEN VX1=-VX1
60 VY1=VY1+M2*SGN(Y2-Y1)/R:Y1=Y1+VY1:IF Y1>475 OR Y1<5 THEN VY1=-VY1
70 VX2=VX2+M1*SGN(X1-X2)/R:X2=X2+VX2:IF X2>635 OR X2<5 THEN VX2=-VX2
80 VY2=VY2+M1*SGN(Y1-Y2)/R:Y2=Y2+VY2:IF Y2>475 OR Y2<5 THEN VY2=-VY2
90 CIRCLE(X1,Y1),4,5:CIRCLE(X2,Y2),4,6
93 LOCATE 0,1:PRINT USING"vx1 ##.### vx2 ##.### vx2 ##.### vy2 ##.###";VX1;VY1,VX2;VY2
100 CIRCLE(X12,Y12),4,0:CIRCLE(X22,Y22),4,0
110 X12=X1:Y12=Y1:X22=X2:Y22=Y2
120 WEND
130 GOTO 20